package com.chilly.other.thread;

public class ThreadInterrupt extends Thread {

    public ThreadInterrupt(String name) {
        super(name);
    }

    @Override
    public void run() {
        while (!interrupted()) {//中断状态判断
            System.err.println(Thread.currentThread().getName() + "线程运行了。。。");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        Thread t1 = new ThreadInterrupt("线程一");
        Thread t2 = new ThreadInterrupt("线程二");
        //启动线程
        t1.start();
        t2.start();
        t1.interrupt();
    }


}